import re


mdFilename='template_match.md'
charpterName='template_match'
lines=[]
with open(mdFilename,'r',encoding='utf-8') as f:
    lines=f.readlines()


def changeOutFilename(temstr):
    def fun(tem):
        tem=str(tem.group())
        res='images_{}/output/{}'.format(charpterName,tem)
        return res
    
    res=re.sub('output\w+.png',fun,temstr)
    return res


def changeImageFilename(temstr):
    def fun(tem):
        filename=tem.group(2)
        res='images_{}/{}'.format(charpterName,filename)
        return res

    res=re.sub('(images)/(\w+.\w{3,3})',fun,temstr)
    return res


for index,line in enumerate(lines):
    lines[index]=changeOutFilename(line)
    lines[index]=changeImageFilename(lines[index])


# for index,line in enumerate(lines):
#     print(line)


with open(mdFilename,'w',encoding='utf-8') as f:
    f.writelines(lines)



